//
//  MVPView.m
//  PrintJob
//
//  Created by blank on 2017/5/8.
//  Copyright (c) 2017 CYN. All rights reserved.
//

#import "MVPView.h"

@interface MVPView ()

@property(nonatomic, retain) UILabel *contentLabel;

@property(nonatomic, retain) UIButton *btnPrint;

@end

@implementation MVPView

- (instancetype)init {
    self = [super init];
    if (self) {
        self.btnPrint;
    }

    return self;
}


- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 30)];
        [self addSubview:_contentLabel];
        [_contentLabel setTextAlignment:NSTextAlignmentCenter];
        [_contentLabel setTextColor:[UIColor blackColor]];
    }

    return _contentLabel;
}

- (UIButton *)btnPrint {
    if (!_btnPrint) {
        _btnPrint = [UIButton buttonWithType:UIButtonTypeSystem];
        [_btnPrint setFrame:CGRectMake(100, 20, 80, 30)];
        [_btnPrint setTitle:@"Print" forState:UIControlStateNormal];
        [_btnPrint addTarget:self
                      action:@selector(printOnClick)
            forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_btnPrint];
    }
    return _btnPrint;
}

- (void)printOnClick {
    if ([_delegate respondsToSelector:@selector(onPrintBtnClick)]) {
        [_delegate onPrintBtnClick];
    }
}

- (void)printOnView:(NSString *)content {
    [self.contentLabel setText:content];
}


@end
